<?php
/******************************************
 * Author: <YOUR NAME HERE>
 * Description: <YOUR DESCRIPTION HERE>
 ******************************************/
class Categorii_recepti extends CustomSecurity { 

	function Categorii_recepti(){ 
    }

	/***********************************
 	 * Add:         Allows the insertion of values into the Table.
 	 * Parameters:  $name
 	 * Return:      (Boolean) True - Successfully Inserted | False - Error
 	 ************************************/
	function add($name){ 

		escape_string($name);

		$statement = "INSERT INTO categorii_recepti (name) VALUES ('$name');";
		$results   = mysql_query($statement);

		if($results){
			return true;
		}else{
			return false;
		}

	}//End add()


	/***********************************
 	 * Remove:      Allows for the removal of record from the database.
 	 * Parameters:  (String)Primary Key Column Name | (Int) Primary Key Value
 	 * Return:      (Boolean) True - Successfully Removed | False - Error
 	 ************************************/
	function remove($primaryKeyValue){ 

		//Custom SQL Injection Escaping HERE

		$statement = "DELETE FROM categorii_recepti WHERE id = '$primaryKeyValue'";
		$results   = mysql_query($statement);
		if($results){
			return true;
		}else{
			return false;
		}

	}//End remove()


	/***********************************
 	 * Update:      Allows for the update of a record from the database.
 	 * Parameters:  (String)Primary Key Column Name | (Int) Primary Key Value | (String) Column Name To Update | (String) New Value
 	 * Return:      (Boolean) True - Successfully Updated | False - Error
 	 ************************************/
	function update($primaryKeyValue, $columnNameToUpdate, $columnValue){ 

		escape_string($primaryKeyValue);
		escape_string($columnNameToUpdate);
		escape_string($columnValue);

		$statement = "UPDATE categorii_recepti SET $columnNameToUpdate = '$columnValue' WHERE id = '$primaryKeyValue'";
		$results   = mysql_query($statement);
		if($results){
			return true;
		}else{
			return false;
		}

	}//End update()


	/***********************************
 	 * GetAll:       Returns all the records in the database.
 	 * Parameters:   NA
 	 * Return:      (MultiDimensional-Array)String
 	 ************************************/
	function getAll(){ 

		//Custom SQL Injection Escaping HERE

		$statement = "SELECT id, name FROM categorii_recepti";
		$mresults   = mysql_query($statement);
		
		$tokens[0] = "id";
		$tokens[1] = "name";
		
		return transformResults($mresults, $tokens);

	}//End getAll()
	
	function getAllNames(){ 

		//Custom SQL Injection Escaping HERE

		$statement = "SELECT name FROM categorii_recepti";
		$mresults   = mysql_query($statement);
		$tokens[0] = "name";
		
		return transformResults($mresults, $tokens);

	}


	/***********************************
 	 * GetObject:   Returns a specific record form the batabase.
 	 * Parameters:  (Int) Primary Key Value
 	 * Return:      (Array)String
 	 ************************************/
	function getObject($primaryKeyValue){ 

		escape_string($primaryKeyValue);
		
		$statement = "SELECT id FROM categorii_recepti WHERE id = '".$primaryKeyValue."'";
		$mresults   = mysql_query($statement);
		
		$tokens[0] = "id";
		
		return transformResults($mresults, $tokens);

	}//End getObject()


}//End Class Categorii_recepti
?>